﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=1">
    <meta name="format-detection" content="telephone=no">
    <meta charset="UTF-8">
    <title>使用lodash库减少watch对后台请求的压力</title>
    <link href="../css/bootstrap.css"/>
    <link href="../css/bootstrap-theme.css"/>
</head>
<body>
    <h1>使用lodash库减少watch对后台请求的压力</h1><br/>

    <div id="app">
        {{name}}
        <input v-model="word"/><br/>
        <p>
            使用lodash库主要是咱们在watch的时候会对服务器造成严重的访问负担<br/>
            时间可以自己设置
        </p>
    </div>
<script src="../js/jquery-2.2.0.min.js"></script>
<script src="../js/vue-2.5.16.js"></script>
<script src="../node_modules/axios/dist/axios.js"></script>
<script src="../node_modules/lodash/lodash.js"></script>

<script>
    var app = new Vue({
        el:'#app',
        watch:{
            word: _.debounce(
                function(newV,oldV){
                    console.log(newV);
                },1000
            )
        },
        data:{
            word:'',
            name:'模版数据'
        }
    });
</script>

</body>
</html>